﻿using aier.dataaccess.model;
using Dapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace aier.dataaccess.dapper
{

    public class CampainDal
    {
        public DapperHelper dapperHelper { get; set; }

        /// <summary>
        /// 获取所有市场活动
        /// </summary>
        /// <returns></returns>
        public List<CampainView> QueryAllCampain()
        {
            List<CampainView> campains = null;
            SqlBuilder sqlBuilder = new SqlBuilder();
            DynamicParameters sqlParams = new DynamicParameters();

            dapperHelper.ExecueWithoutTransaction(a =>
            {
                string sql = @"select * from AIER_CAMPAIN_INFO";
                var sqlTemplate = sqlBuilder.AddTemplate(sql);

                campains = a.Query<CampainView>(sqlTemplate.RawSql, sqlParams).ToList();
            });

            return campains;
        }

    }
}
